//
//  HNHomeMainCell.m
//  HappyNews
//
//  Created by baiping on 15/12/29.
//  Copyright © 2015年 bai wang. All rights reserved.
//

#import "HNHomeMainCell.h"
#import "UIImageView+WebCache.h"

@interface HNHomeMainCell()

@end

@implementation HNHomeMainCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        _iconImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 15, 70, 60)];
        
        [self.contentView addSubview:_iconImage];
        
       
        
        _contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(_iconImage.right + 10, _iconImage.top, kScreenWidth - _iconImage.right - 20, 90)];
        
        
        _contentLabel.numberOfLines = -1;
        
        [self.contentView  addSubview:_contentLabel];
        
    }
    
    return self;
    
}

- (void)setModel:(HNHomeMainModel *)model{
    
    [_iconImage sd_setImageWithURL:[NSURL URLWithString:model.images[0]] placeholderImage:nil];
    
    _contentLabel.text = model.title;
    
    CGSize size = CGSizeMake(kScreenWidth - _iconImage.right - 20, MAXFLOAT);
    
    CGSize sizeNew = [_contentLabel.text sizeWithFont:[UIFont systemFontOfSize:20]constrainedToSize:size];
    
    _contentLabel.frame = CGRectMake(_iconImage.right + 10, _iconImage.top, sizeNew.width, sizeNew.height);
    
}


@end
